package org.filecollector.filecontroller.virtualcatalogue.virtualfile;

import lombok.NonNull;

import java.io.File;
import java.util.regex.Pattern;
/**
 * Record contains data of {@link VirtualFileClass}
 * @param innerFile is file that be tracked by program
 * @param id is file's id
 */
public record VirtualFileDao(@NonNull File innerFile, @NonNull Long id) {

    /**
     * RegEx pattern that allows to parse file name. File name should pe positive long number
     */
    private static final Pattern FILE_NAME_PATTERN = Pattern.compile("^([0-7]?[0-9A-F]{1,15})$");

    /**
     * @return RegEx pattern
     */
    public static Pattern getFileNamePattern() {
        return FILE_NAME_PATTERN;
    }

    /**
     * Constructs Dao
     * @param id identificator
     * @param file tracking file
     * @return new Dao
     */
    public static VirtualFileDao construct(Long id, File file) {
        return new VirtualFileDao(file, id);
    }
}
